#coding:utf-8

class Word(str):
    "存储单词的类，定义比较单词的几种方法"

    def __new__(cls,word):
        #注意我们必须用到__new__方法，因为str是不可变类型
        #所以我们必须在创建的时候将它初始化
        word = "kk"+word
        return str.__new__(cls,word)
    
    #def __init__(self,word):
    #    word = "kk"+word                #does not work
    #    return str.__init__(self,word)

    def __gt__(self,other):      
        #调用>会调用__gt__()
        return len(self) > len(other) 
    def __lt__(self,other):
        return len(self) < len(other)

if __name__ == '__main__':
    a = Word("lkk")
    b = Word("ss")
    print "a:"+a
    print "b:"+b
    if (b < a):
        print "yes"
